perm filename SUBWIN.BAK[XAP,BGB] blob sn#049123 filedate 1973-06-18 generic text, type T, neo UTF8
NOTBLW:	SKIPE FOO		;Was old window used?
	GO WDONE		;YES
	CALL RINGOUT,W1		;Consider it empty
	PUSHP 1
	CALL KLNODE,W1
	POPP W1
	SKIPA
WDONE:	CCW W1,W1		;Window done, get next
	CAME W1,W0		;At end?
	JUMPN W1,WLOOP		;No, do next window
ADONE:	CCW A1,A1		;Area done
	CAME A1,A0		;At end of area ring?
	GO ALOOP		;No, do next area
	LAC 1,WINDOW		;Return window if anyone cares.
	POP2J
NSUBR SUBWINDOW,PAGE,WINDOW
	LAP NEW,WINDOW
	RMIN NR1,NEW		;Fetch limits of window
	RMAX NR2,NEW
	CMIN NC1,NEW
	CMAX NC2,NEW
	SKIPN 1,PAGE		;Make sure there's a window here.
	FATAL<No page at SUBWINDOW!>
	SON A0,1
	SKIPN A1,A0
	POP2J			;No areas, quick exit!
ALOOP:	SON W0,A1		;For each area.
	SKIPN W1,W0		;If there is one...
	GO ADONE
WLOOP:	RMIN OR1,W1		;For each window
	RMAX OR2,W1
	CAMGE OR1,NR2		;Is rows of new window within rows of old?
	CAML OR2,NR2
	GO WDONE		;No, this window OK.
	CMIN OC1,W1
	CMAX OC2,W1
	CAMGE OC1,NC2		;Are columns of new window within columns of old?
	CAML OC1,NC2
	GO WDONE		;No, this window OK.
	SETZM FLAG		;Clear flag indicated node has been used.
	CAMG NR1,OR1		;Does new window extend above old window?
	GO NOTABV		;Yes, part old window is not above new window
;	CALL AFTER		;(We don't need to make a window as old one not used.)
	RMAX. NR1,W1		;Change make beginning of new window be end of old.
	SETOM FOO		;We have used old window.
NOTABV:	CAMG NC1,OC1		;Is there anything to the left of new window?
	GO NOTLFT		;No, not left of window
	CALL MIDDLE		;Set rows
	CMIN. OC1,W1		;Set columns
	CMAX. NC2,W1
NOTLFT:	CAMG NC1,OC1		;Is there anything to the right of new window?
	GO NOTRGT		;No, not right of window
	CALL MIDDLE		;Set rows
	CMIN. NC1,W1		;Set columns
	CMAX. OC2,W1
;Make window to left or right of new window.
MIDDLE:	CALL AFTER		;Get a window after old window.
	RMIN. NR1,W1		;Set top of window.
	RMAX. NR2,W1		;Set bottom of window.
	CAMGE NR2,OR2		;Did we use the lower one?
	RMAX. OR2,W1		;Oops, use other one.
	POP0J			;Return
NOTRGT:	CAML NR2,OR2		;Is there anything below new window?
	GO NOTBLW		;No, not below.
	CALL AFTER		;Get a window after old window.
	RMIN. NR2,W1		;Set rows.
	RMAX. OR2,W1
	CMIN. OC1,W1		;Set columns.
	CMAX. OC2,W1